package io.gitee.macxiang.entity;

/**
 * 返回结果是实体类的查询构造器
 * @param <T> 返回结果实体类
 */
public class ExecEntity<T> {
  final public String sql;

  @FunctionalInterface
  public interface SqlExecCallback<T> {
    T process(String input);
  }

  final private SqlExecCallback<T> callback;

  public ExecEntity(String sql, SqlExecCallback<T> callback) {
    this.sql = sql;
    this.callback = callback;
  }

  public T exec() {
    if (callback != null) {
      return callback.process(sql);
    }
    return null;
  }
}
